package com.ws.shop.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ws.shop.bean.Page;
import com.ws.shop.dao.LinksDao;
import com.ws.shop.entity.Links;
import com.ws.shop.service.LinksService;

@Service(value="linksService")
public class LinksServiceImpl implements LinksService {
	@Resource(name="linksDao")
	private LinksDao linksDao;

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page findByPage(int pageno,int pagesize) {
		return linksDao.findByPage(pageno,pagesize);
	}

	@CacheEvict(value="linksColl",allEntries=true)
	@Transactional(rollbackFor=Exception.class)
	public void saveOrUpdate(Links links) {
		linksDao.saveOrUpdate(links);
	}
	
	@Cacheable(value="linksColl")
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<Links> findLinksList(int state){
		return linksDao.findLinksList(state);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Links findLinksById(int id) {
		return linksDao.findLinksById(id);
	}
}
